<template>
  <div class="container" style="min-width: 970px">
    <!-- 抄表营销 - 营业收费 -->
    <el-form :inline="true" class="tableSearchBox" size="medium" @submit.native.prevent>
      <el-form-item label>
        <el-select v-model="search.type" placeholder="请选择" @change="clearSearch">
          <el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input v-if="search.type=='userID'" v-model.trim="search.userID" placeholder="请输入用户编号"
          @keyup.enter.native="getSearch" clearable />
        <el-input v-if="search.type=='phone'" v-model.trim="search.phone" placeholder="请输入手机号"
          @keyup.enter.native="getSearch" clearable />
        <el-input v-if="search.type=='name'" v-model.trim="search.name" placeholder="请输入姓名"
          @keyup.enter.native="getSearch" clearable />
        <el-input v-if="search.type=='address'" v-model.trim="search.address" placeholder="请输入小区名"
          @keyup.enter.native="getSearch" clearable />
        <el-input v-if="search.type=='meterID'" v-model.trim="search.meterID" placeholder="请输入编号"
          @keyup.enter.native="getSearch" clearable />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="getSearch">查询</el-button>
      </el-form-item>

      <!-- test -->
      <!-- <el-form-item>
        <el-date-picker v-model="time" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择滞纳金时间"
          :editable="false" :clearable="false"></el-date-picker>
        <el-button type="danger" icon="el-icon-sunny" @click="test5()">修改滞纳金时间</el-button>
      </el-form-item> -->
      <el-form-item class="fr">
        <el-button type="success" size="mini" icon="el-icon-discount" @click="getChargeToday">今日收费</el-button>
      </el-form-item>
      <div class="clear"></div>
    </el-form>
    <div style="padding:0px 20px 20px 20px;">
      <div class="mb20">
        <div class="fl" style="width:460px">
          <fieldset class="sanfan-fieldset">
            <legend>
              <el-dropdown @command="handleCommand">
                <span class="el-dropdown">
                  {{dropdownList[dropdownValue].name}} <i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="(item,index) in dropdownList" :key="index" :command="index">{{item.name}}
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </legend>
            <div class="tableDetail" v-if="dropdownValue==0">
              <table class="table">
                <tr>
                  <!-- 水表号当用户编号 -->
                  <th>用户编号</th>
                  <td>{{currentObj.mainMeterID}}</td>
                  <th>户表类型</th>
                  <td>{{currentObj.userMeterTypeName}}</td>
                </tr>
                <tr>
                  <th>用户姓名</th>
                  <td colspan="3">{{currentObj.name}}</td>
                </tr>
                <tr>
                  <th>用户状态</th>
                  <td>
                    <span v-if="currentObj.status==1">正常</span><span v-if="currentObj.status==0"
                      class="fc-red">停用中</span>
                  </td>
                  <th>联系方式</th>
                  <td>{{currentObj.phone}}</td>
                </tr>
                <tr>
                  <th>联系方式2</th>
                  <td>{{currentObj.phoneA}}</td>
                  <th>联系方式3</th>
                  <td>{{currentObj.phoneB}}</td>
                </tr>
                <tr>
                  <th>地址</th>
                  <td colspan="3">{{currentObj.villageName}} {{currentObj.villageDetail}}</td>
                </tr>
                <tr>
                  <th>用水类型</th>
                  <td>{{currentObj.waterRateName}}</td>
                  <th>欠费状态</th>
                  <td>
                    <span v-if="currentObj.meterUserStatus==0">正常</span><span v-if="currentObj.meterUserStatus==1"
                      class="fc-red">欠费</span>
                  </td>
                </tr>
                <tr>
                  <th>预存水量</th>
                  <td>{{currentObj.depositWater}} 吨</td>
                  <th>当前余额</th>
                  <td>{{currentObj.depositMoney}} 元</td>
                </tr>
                <!-- <tr>
                  <th>水量充值</th>
                  <td colspan="3">
                    <el-input v-model="money" placeholder="0.00" size="mini" style="width:100px" type="number">
                      <template slot="append" style="width:30px">元</template>
                    </el-input>
                    <el-button type="success" icon="el-icon-mouse" @click="moneyCompute(money)" size="mini">计算</el-button>
                    <span class="tip">
                      可购
                      <span class="f14 fc-red">{{moneyToWater}}</span> 吨水
                    </span>
                    <div class="mb10"></div>
                    <el-button class="m" type="danger" icon="el-icon-s-finance" @click="moneyAdd(money)" size="mini"
                      :disabled="currentObj.status!=1">确定充值</el-button>
                  </td>
                </tr> -->
              </table>
            </div>
            <div v-else>
              <PagesTable :tableHeader="tableHeaderMeter" :tableData="tableDataMeter"
                :tableOperation="tableOperationMeter" :tablePagination="tablePaginationMeter" />
            </div>
          </fieldset>
        </div>
        <div class="fr" style="width:calc(100% - 480px)">
          <fieldset class="sanfan-fieldset">
            <legend>缴费信息</legend>
            <div v-if="!showPrintBtn">
              <el-form ref="form" :model="form" :inline="true" label-width="90px" class="tableSearchBox yysfBox"
                size="mini" style="border:0;padding-top:0" @submit.native.prevent>
                <!-- <el-form-item label="账单号：">
                {{form.ids}}
                </el-form-item>-->
                <el-form-item label="总用水量：">{{form.currWaterCount}}</el-form-item>
                <!-- <el-form-item label="水量抵扣：">{{form.fromDepositWater}}</el-form-item> -->
                <el-form-item label="水费：">{{form.waterFee}}</el-form-item>
                <el-form-item label="水资源税：">{{form.tax}}</el-form-item>
                <el-form-item label="污水费：">{{form.effluentFee}}</el-form-item>
                <!-- <el-form-item label="其他费用：">{{form.otherFee}}</el-form-item> -->
                <el-form-item label="滞纳金：">{{form.lateFee}}</el-form-item>
                <br />
                <div class="border dashed mb10"></div>
                <el-form-item label="合计：">{{form.totalFee}}</el-form-item>
                <el-form-item label="余额抵扣：">{{form.fromDepositMoney}}</el-form-item>
                <br />
                <el-form-item label="应缴金额：" class="fc-red">
                  {{form.needPay}}
                  <span class="f18"></span>
                </el-form-item>
                <el-form-item label="打印发票：">
                  <el-radio-group v-model="form.isPrint">
                    <el-radio label="1">是</el-radio>
                    <el-radio label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
                <br />
                <el-form-item label="实收：" size="medium">
                  <el-input ref="inputCalculateFee" v-model="form.calculateFee" style="width:150px" placeholder="0.00"
                    @focus="focusCalculateFee" @input="changeCalculateFee">
                    <template slot="append">元</template>
                  </el-input>
                </el-form-item>
                <el-form-item v-if="form.ids.length>0" label="找零：">{{formatFixed(form.calculateFee-form.needPay)}}
                </el-form-item>
                <el-form-item>
                  <el-checkbox v-model="form.checked">零钱转入</el-checkbox>
                </el-form-item>
                <div v-if="form.ids.length>0">
                  <el-form-item label="本次结余："
                    v-if="formatFixed(form.calculateFee-form.needPay+Number(form.depositMoney-form.fromDepositMoney))>0">
                    {{formatFixed(form.calculateFee-form.needPay+Number(form.depositMoney-form.fromDepositMoney))}}
                    <span v-if="form.allPrice!=0">
                      （自动存入水量：{{parseInt(formatFixed(form.calculateFee-form.needPay+Number(form.depositMoney-form.fromDepositMoney))/form.allPrice)}}吨，
                      余：{{formatFixed((form.calculateFee-form.needPay+Number(form.depositMoney-form.fromDepositMoney))%form.allPrice)}}
                      元）
                    </span>
                  </el-form-item>
                </div>
                <div v-else>
                  <el-form-item label="本次结余：">
                    {{formatFixed(moneyToCurrSurplus)}}
                    <span v-if="form.allPrice!=0">
                      （自动存入水量：{{moneyToWater}}吨，
                      余：{{formatFixed(moneyToCurrSurplus)}}
                      元）
                    </span>
                  </el-form-item>
                </div>
                <el-form-item label=" " size="medium">
                  <el-button type="primary" @click="onSubmit" :disabled="currentObj.status!=1">
                    <template v-if="form.ids.length>0">
                      确定缴费
                    </template>
                    <template v-else>
                      确定充值
                    </template>
                  </el-button>
                </el-form-item>
              </el-form>
            </div>
            <div v-else>
              <el-form :inline="true" class="fl">
                <el-form-item label="用户姓名：" class="print_form_item">{{currentObj.name}}</el-form-item>
                <el-form-item label="用户地址：" class="print_form_item">{{currentObj.villageName}}
                  {{currentObj.villageDetail}}</el-form-item>
              </el-form>
              <div class="fr">
                <el-button type="primary" icon="el-icon-printer" :disabled="WreceiptBtn" @click="WPrintWaitLoop">水费票
                </el-button>
                <el-button type="primary" icon="el-icon-printer" :disabled="SWreceiptBtn" @click="SWPrintWaitLoop">污水票
                </el-button>
                <el-button icon="el-icon-back" @click="onReturn">返回缴费</el-button>
              </div>
              <PagesTable ref="printTable" tableMaxHeight="245px" :tableHeader="tableHeaderPrint"
                :tableData="tableDataPrint" :tablePagination="tablePaginationPrint" />
            </div>
          </fieldset>
        </div>
        <div class="clear"></div>
      </div>

      <el-tabs class="tableMt" type="card" v-model="activeName" @tab-click="bottomTabClick">
        <el-tab-pane label="欠费记录" name="first">
          <!-- 欠费记录 -->
          <PagesTable ref="multipleTable" :isIndex="true" :isSelection="true" :tableHeader="tableHeader1"
            :tableData="tableData1" :tablePagination="tablePagination1" :tableOperation="tableOperation1"
            @selectionChange="selectionChange" @pageOperation="handlePageOperation3" @pageSize="pageSizeChange1"
            @currentPage="currentPageChange1" />
        </el-tab-pane>
        <el-tab-pane label="缴费记录" name="second">
          <!-- 缴费记录 -->
          <el-table class="sanfan-table" border :data="tableData2" style="width: 100%;table-layout:fixed;"
            :span-method="objectSpanMethod" :highlight-current-row="true">
            <el-table-column v-for="(item,index) in tableHeader2" :key="index" :prop="item.mark"
              :label="item.unit?item.name+'('+item.unit+')':item.name" :min-width="item.minWidth" :width="item.width"
              align="center" :show-overflow-tooltip="true" :fixed="item.fixed">
              <template slot-scope="scope">
                <span v-if="item.mark"
                  :class="(scope.row[item.mark]!==null&&scope.row[item.mark]!==undefined?(scope.row[item.mark].value<scope.row[item.mark].min||scope.row[item.mark].value>scope.row[item.mark].max):false)?'red':(item.color?item.color[scope.row[item.marks]]:'')">{{scope.row[item.mark]!==null&&scope.row[item.mark]!==undefined?(scope.row[item.mark].value?scope.row[item.mark].value:(item.list?item.list[scope.row[item.mark]]:(item.showList?(item.showList[scope.row[item.marks]]?scope.row[item.mark]:'-'):(item.toFixedNum?scope.row[item.mark].toFixed(item.toFixedNum):scope.row[item.mark])))):''}}</span>
                <div v-else>
                  <el-button v-for="(it,i) in tableOperation2" :key="'font'+i"
                    v-show="!it.icon&&(it.list?it.list[scope.row[it.mark]]:it.name)"
                    @click="handlePageOperation2(scope.row,it.mark,scope.$index)" size="mini" class="themeBtn"
                    :disabled="currentObj.status!=1">{{it.list?it.list[scope.row[it.mark]]:it.name}}</el-button>
                  <el-button :title="it.name" v-for="(it,i) in tableOperation2" :key="'icon'+i"
                    v-show="it.icon&&(it.list?it.list[scope.row[it.mark]]:it.mark)"
                    :icon="'el-icon-'+(it.list?it.list[scope.row[it.mark]]:it.mark)" circle
                    @click="handlePageOperation2(scope.row,it.mark,scope.$index)" size="mini" class="themeBtn"
                    :disabled="currentObj.status!=1"></el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <el-pagination v-show="tablePagination2.show" @size-change="pageSizeChange2"
            @current-change="currentPageChange2" :current-page="tablePagination2.current"
            :page-sizes="[10, 20, 50, 100]" :page-size="tablePagination2.size" background
            layout="total, sizes, prev, pager, next, jumper" :total="tablePagination2.total"></el-pagination>
          <!-- /缴费记录 -->
        </el-tab-pane>
        <el-tab-pane label="抄表记录" name="third">
          <el-table class="sanfan-table" border :data="tableData3" style="width: 100%;table-layout:fixed;"
            :highlight-current-row="true" v-if="1==1">
            <el-table-column v-for="(item,index) in tableHeader3" :key="index" :prop="item.mark"
              :label="item.unit?item.name+'('+item.unit+')':item.name" :min-width="item.minWidth" :width="item.width"
              align="center" :show-overflow-tooltip="true" :fixed="item.fixed">
              <template slot-scope="scope">
                <span v-if="item.mark"
                  :class="(scope.row[item.mark]!==null&&scope.row[item.mark]!==undefined?(scope.row[item.mark].value<scope.row[item.mark].min||scope.row[item.mark].value>scope.row[item.mark].max):false)?'red':(item.color?item.color[scope.row[item.marks]]:'')">{{scope.row[item.mark]!==null&&scope.row[item.mark]!==undefined?(scope.row[item.mark].value?scope.row[item.mark].value:(item.list?item.list[scope.row[item.mark]]:(item.showList?(item.showList[scope.row[item.marks]]?scope.row[item.mark]:'-'):(item.toFixedNum?scope.row[item.mark].toFixed(item.toFixedNum):scope.row[item.mark])))):''}}</span>

                <!-- 单独的操作按钮判断 -->
                <div v-else>
                  <el-button title="取消抄表" v-if="scope.row.meterReadingRecordStatus==1" size="mini" class="themeBtn"
                    @click="handlePageOperation3(scope.row,'refresh-left',scope.$index)"
                    :disabled="currentObj.status!=1">取消抄表</el-button>
                  <el-button title="取消缴费" v-else size="mini" class="themeBtn"
                    @click="handlePageOperation3(scope.row,'close',scope.$index)" :disabled="currentObj.status!=1">取消缴费
                  </el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <el-pagination v-show="tablePagination3.show" @size-change="pageSizeChange3"
            @current-change="currentPageChange3" :current-page="tablePagination3.current"
            :page-sizes="[10, 20, 50, 100]" :page-size="tablePagination3.size" background
            layout="total, sizes, prev, pager, next, jumper" :total="tablePagination3.total"></el-pagination>
        </el-tab-pane>
        <el-tab-pane label="充值记录" name="fourth">
          <PagesTable :isIndex="true" :tableHeader="tableHeader4" :tableData="tableData4"
            :tablePagination="tablePagination4" :tableOperation="tableOperation4" @pageOperation="handlePageOperation4"
            @pageSize="pageSizeChange4" @currentPage="currentPageChange4" />
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-dialog title="选择用户" :visible.sync="showUserList" width="90%">
      <div class="fc-red mb10">tip：单击表格行高亮选中用户后，点击“确定”按钮查看此用户详细信息</div>
      <div>
        <PagesTable :isIndex="true" :tableHeader="tableHeader" :tableData="tableData" :tablePagination="tablePagination"
          @pageSize="pageSizeChange" @currentPage="currentPageChange" @selectionChange="slectUserIDByTable" />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showUserList = false">取 消</el-button>
        <el-button type="primary" @click="changeUser">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="今日收费" :visible.sync="showChargeToday" width="90%">
      <div style="min-height:400px">
        <el-tabs v-model="chargeTodayActiveName" type="card">
          <el-tab-pane label="收费记录" name="one">
            <PagesTable tableMaxHeight="400px" :isIndex="true" :border="true" :tableID="'tableChargeToday'" :tableSpan="tableSpan"
              :tableHeader="tableHeaderChargeToday" :tableData="tableDataChargeToday"
              :tablePagination="tablePaginationChargeToday" @pageSize="pageSizeChangeChargeToday"
              @currentPage="currentPageChangeChargeToday" />
          </el-tab-pane>
          <el-tab-pane label="充值记录" name="two">
            <PagesTable tableMaxHeight="400px" :isIndex="true" :border="true" :tableHeader="tableHeaderChargeToday2"
              :tableData="tableDataChargeToday2" :tablePagination="tablePaginationChargeToday2"
              @pageSize="pageSizeChangeChargeToday2" @currentPage="currentPageChangeChargeToday2" />
          </el-tab-pane>
          <el-tab-pane label="收费合计" name="three">
            <div class="tableDetail">
              <table class="table sanfan-table">
                <thead>
                  <tr>
                    <th class="align_c">用水类型</th>
                    <th class="align_c">用水量(吨)</th>
                    <th class="align_c">水票费(元)</th>
                    <th class="align_c">水资源税(元)</th>
                    <th class="align_c">污水费(元)</th>
                    <th class="align_c">实收现金(元)</th>
                  </tr>
                </thead>
                <tr v-for="(item,index) in dailyChargeClassify" :key="index">
                  <td class="align_c">{{item.waterRateName}}</td>
                  <td class="align_c">{{item.currWaterCount}}</td>
                  <td class="align_c">{{item.waterAndLate}}</td>
                  <td class="align_c">{{item.sumRealTax}}</td>
                  <td class="align_c">{{item.sumRealEffluentFee}}</td>
                  <td class="align_c">{{item.realPaymentMoney}}</td>
                </tr>
                <tr>
                  <th class="align_c">合计</th>
                  <th class="align_c">{{dailyChargeData.currWaterCount}}</th>
                  <th class="align_c">{{dailyChargeData.waterAndLate}}</th>
                  <th class="align_c">{{dailyChargeData.tax}}</th>
                  <th class="align_c">{{dailyChargeData.effluent}}</th>
                  <th class="align_c">{{dailyChargeData.realPaymentMoney}}</th>
                </tr>
              </table>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import PagesTable from "../components/PagesTable.vue";
  var LODOP; //声明为全局变量
  export default {
    components: {
      PagesTable
    },
    data() {
      return {
        time: "", //测试滞纳金时间
        waterFeeWaiver: "",
        effluentFeeWaiver: "",
        // otherFeeWaiver: "",
        taxWaiver: "",
        lateFeeWaiver: "", //测试减免参数
        search: {
          type: "meterID",
          userID: "",
          phone: "",
          name: "",
          address: "",
          meterID: ""
        },
        dropdownValue: 0,
        dropdownList: [{
            id: 0,
            name: "用户信息"
          },
          {
            id: 1,
            name: "水表信息"
          },
        ],
        money: 0,
        moneyToWater: 0,
        moneyToCurrSurplus: 0,
        activeName: "first",
        showPrintBtn: false,
        showChargeToday: false,
        showUserList: false,
        currentObj: {},
        typeOptions: [{
            value: "meterID",
            label: "用户编号" //水表号当用户编号
          },
          {
            value: "phone",
            label: "手机号"
          },
          {
            value: "name",
            label: "姓名"
          },
          {
            value: "address",
            label: "住址"
          }
        ],
        //用户列表
        tablePagination: {
          show: true,
          current: 1,
          size: 10,
          total: 0
        },
        tableHeader: [{
            name: "用户编号",
            mark: "meterID" //水表号当用户编号
          },
          {
            name: "用户姓名",
            mark: "name"
          },
          {
            name: "别名",
            mark: "aliasName"
          },
          {
            name: "手机号",
            mark: "phone"
          },
          {
            name: "小区名称",
            mark: "villageName"
          },
          {
            name: "详细地址",
            mark: "villageDetail"
          },
          {
            name: "用水类型",
            mark: "waterRateName"
          },
          {
            name: "状态",
            mark: "status",
            list: {
              0: "欠费",
              1: "正常"
            }
          }
        ],
        tableData: [],
        //打印信息
        tableHeaderPrint: [{
            name: "用户编号",
            mark: "meterID" //水表号当用户编号
          },
          {
            name: "账期",
            mark: "period"
          },
          {
            name: "用水类型",
            mark: "waterRateName"
          },
          {
            name: "用水量",
            mark: "currWaterCount"
          },
          {
            name: "预存水量",
            mark: "currDepositWater"
          },
          {
            name: "水票费",
            mark: "receiptTotalFee"
          },
          {
            name: "水资源税",
            mark: "tax"
          },
          {
            name: "水税合计",
            mark: "waterTaxSum"
          },
          {
            name: "污水单价",
            mark: "currEffluentFee"
          },
          {
            name: "污水费",
            mark: "effluentFee"
          },
          {
            name: "合计",
            mark: "allSum"
          },
        ],
        tableDataPrint: [],
        tablePaginationPrint: {
          show: false,
          current: 1,
          size: 10,
          total: 0
        },
        //欠费记录
        tablePagination1: {
          show: false,
          current: 1,
          size: 10,
          total: 0
        },
        tableHeader1: [{
            name: "账单编号",
            mark: "meterReadingRecordID"
          },
          {
            name: "用户编号",
            mark: "meterID"
          },
          {
            name: "用水类型",
            mark: "waterRateName"
          },
          {
            name: "上期底数",
            mark: "lastReadingValue"
          },
          {
            name: "本期底数",
            mark: "currReadingValue"
          },
          {
            name: "抵扣水量",
            mark: "readingFromDepositWater"
          },
          {
            name: "用水量",
            mark: "currWaterCount"
          },
          {
            name: "水费",
            mark: "waterFee"
          },
          {
            name: "水资源税",
            mark: "tax"
          },
          {
            name: "污水费",
            mark: "effluentFee"
          },
          // {
          //   name: "其他费用",
          //   mark: "otherFee"
          // },
          {
            name: "滞纳金",
            mark: "lateFee"
          },
          {
            name: "滞纳天数",
            mark: "lateDays"
          },
          {
            name: "总水费",
            mark: "totalFee"
          },
          {
            name: "总减免",
            mark: "totalWaiver"
          },
          {
            name: "应缴",
            mark: "totalRealFee"
          },
          // {
          //   name: '是否结算',
          //   mark: 'meterReadingRecordStatus',
          //   list: {
          //     "-1": "作废",
          //     1: "未结算",
          //     2: "已结算",//手动结算
          //     3: "自动结算",//扣余额
          //     4: "自动结算",//扣水量
          //     5: "自动结算",//扣余额和水量
          //   },
          // },
          {
            name: "抄表时间",
            mark: "recordTime",
            width: "160"
          },
          {
            name: "操作",
            mark: "",
            width:"100",
            fixed: "right"
          }
        ],
        tableOperation1: [{
          name: "取消抄表",
          mark: "refresh-left",
          icon: false
        }],
        tableData1: [],
        //缴费记录
        tablePagination2: {
          show: true,
          current: 1,
          size: 10,
          total: 0
        },
        tableHeader2: [{
            name: "缴费编号",
            mark: "userPayingRecordID",
            width: "80",
            fixed: true
          },
          // {
          //   name: "缴费单号",
          //   mark: "payTag",
          //   width: "100",
          //   fixed: true
          // },
          {
            name: "账单编号",
            mark: "meterReadingRecordID"
          },
          // {
          //   name: '开启阶梯',
          //   mark: 'ladderStatus'
          // },

          // {
          //   name: 'meterPayingRecordID',
          //   mark: 'meterPayingRecordID'
          // },
          {
            name: "抵扣水量",
            mark: "readingFromDepositWater"
          },
          {
            name: "用水量",
            mark: "currWaterCount"
          },
          {
            name: "水费",
            mark: "realWaterFee"
          },
          {
            name: "水资源税",
            mark: "realTax"
          },
          {
            name: "污水费",
            mark: "realEffluentFee"
          },
          // {
          //   name: "其他费用",
          //   mark: "realOtherFee"
          // },
          {
            name: "滞纳金",
            mark: "realLateFee"
          },
          {
            name: "滞纳天数",
            mark: "lateDays"
          },
          {
            name: "小计",
            mark: "realTotalFee"
          },
          {
            name: "应收",
            mark: "sumPay"
          },
          {
            name: "实收现金",
            mark: "realPaymentMoney"
          },
          {
            name: "余额抵扣",
            mark: "fromDepositMoney"
          },
          {
            name: "现金抵扣",
            mark: "realPay"
          },
          // {
          //   name: "水量抵扣",
          //   mark: "fromDepositWater"
          // },
          // {
          //   name: "存入余额",
          //   mark: "realSurplusMoney"
          // },
          {
            name: "存入水量",
            mark: "depositWaterCount"
          },
          {
            name: "上期余额",
            mark: "lastSurplus"
          },
          {
            name: "本期余额",
            mark: "currSurplus"
          },
          {
            name: "缴费状态",
            mark: "meterPayingRecordStatus",
            list: {
              "-1": "作废",
              1: "未结算",
              2: "已结算", //手动结算
              3: "自动结算", //扣余额
              4: "自动结算", //扣水量
              5: "自动结算" //扣余额和水量
            }
          },
          {
            name: "缴费时间",
            mark: "userPayingRecordCreateTime",
            width: "160"
          },
          // {
          //   name: '缴费时间',
          //   mark: 'payTime'
          // },
          // {
          //   name: '收据状态',
          //   mark: 'receiptStatus'
          // },

          {
            name: "操作",
            mark: "",
            width:"100",
            fixed: "right"
          }
        ],
        tableOperation2: [{
          name: "取消缴费",
          mark: "close",
          icon: false
        }],
        tableData2: [],
        //抄表记录
        tablePagination3: {
          show: true,
          current: 1,
          size: 10,
          total: 0
        },
        tableHeader3: [{
            name: "账单编号",
            mark: "meterReadingRecordID"
          },
          {
            name: "用户编号",
            mark: "meterID"
          },
          {
            name: "用水类型",
            mark: "waterRateName"
          },
          {
            name: "上期底数",
            mark: "lastReadingValue"
          },
          {
            name: "本期底数",
            mark: "currReadingValue"
          },
          {
            name: "抵扣水量",
            mark: "readingFromDepositWater"
          },
          {
            name: "用水量",
            mark: "currWaterCount"
          },
          {
            name: "水费",
            mark: "waterFee"
          },
          {
            name: "水资源税",
            mark: "tax"
          },
          {
            name: "污水费",
            mark: "effluentFee"
          },
          // {
          //   name: "其他费用",
          //   mark: "otherFee"
          // },
          {
            name: "滞纳金",
            mark: "lateFee"
          },
          {
            name: "滞纳天数",
            mark: "lateDays"
          },
          {
            name: "总水费",
            mark: "totalFee"
          },
          {
            name: "总减免",
            mark: "totalWaiver"
          },
          {
            name: "应缴",
            mark: "totalRealFee"
          },
          {
            name: "是否结算",
            mark: "meterReadingRecordStatus",
            list: {
              "-1": "作废",
              1: "未结算",
              2: "已结算", //手动结算
              3: "自动结算", //扣余额
              4: "自动结算", //扣水量
              5: "自动结算" //扣余额和水量
            }
          },
          {
            name: "抄表时间",
            mark: "recordTime",
            width: "160"
          },
          {
            name: "操作",
            mark: "",
            width:"100",
            fixed: "right"
          }
        ],
        tableOperation3: [{
            name: "取消抄表",
            mark: "refresh-left",
            icon: true
          },
          {
            name: "取消缴费",
            mark: "close",
            icon: true
          }
        ],
        tableData3: [],
        //充值记录
        tablePagination4: {
          show: true,
          current: 1,
          size: 10,
          total: 0
        },
        tableHeader4: [{
            name: "缴费编号",
            mark: "userPayingRecordID"
          },
          {
            name: "用水类型",
            mark: "waterRateName"
          },
          {
            name: "用水单价",
            mark: "allPrice"
          },
          {
            name: "上期余额",
            mark: "lastSurplus"
          },
          {
            name: "充值金额(元)",
            mark: "realPaymentMoney"
          },
          {
            name: "购买水量(吨)",
            mark: "depositWaterCount"
          },
          {
            name: "本期余额",
            mark: "currSurplus"
          },
          {
            name: "充值时间",
            mark: "userPayingREcordCreateTime"
          },
          {
            name: "操作员",
            mark: "cashierName"
          },
          {
            name: "操作",
            width:"100",
            mark: ""
          }
        ],
        tableOperation4: [{
          name: "取消充值",
          mark: "close",
          icon: false
        }],
        tableData4: [],

        form: {
          ids: [], //账单号
          isPrint: "1", //是否打印发票
          checked: true, //是否找零
          calculateFee: "0.00", //建议实收
          currWaterCount: "0", //用水量
          lateFee: "0.00", //滞纳金
          effluentFee: "0.00", //污水费
          // otherFee: "0.00", //其他费用
          tax: "0.00", //税费
          totalFee: "0.00", //合计
          needPay: 0, //应缴
          waterFee: "0.00", //水费
          fromDepositMoney: "0.00", //余额抵扣
          allPrice: "1", //费用/每吨水
          depositMoney: "0" //账户余额
          // fromDepositWater: "0" //水量抵扣
        },
        tablePaginationChargeToday: {
          show: true,
          current: 1,
          size: 10,
          total: 0
        },
        tablePaginationChargeToday2: {
          show: true,
          current: 1,
          size: 10,
          total: 0,
        },
        chargeTodayActiveName: "one",
        tableSpan: {
          mark: "userPayingRecordID",
          colsIndex: [0, 1, 3, 4, 12, 13]
        },
        tableHeaderChargeToday: [{
            name: "缴费编号",
            mark: "userPayingRecordID",
            fixed: "left"
          },
          {
            name: "用户编号",
            mark: "meterID",
            fixed: "left"
          },
          {
            name: "用户姓名",
            mark: "name",
            fixed: "left"
          },
          {
            name: "小区",
            mark: "villageName"
          },
          {
            name: "账单编号",
            mark: "meterReadingRecordID"
          },
          {
            name: "用水类型",
            mark: "waterRateName"
          },
          {
            name: "用水量",
            mark: "currWaterCount"
          },
          {
            name: "预存水量",
            mark: "currDepositWater"
          },
          // {
          //   name: "水费",
          //   mark: "realWaterFee"
          // },
          {
            name: "水票费",
            mark: "receiptTotalFee"
          },
          {
            name: "水资源税",
            mark: "tax"
          },
          {
            name: "污水费",
            mark: "effluentFee"
          },
          // {
          //   name: "滞纳金",
          //   mark: "realLateFee"
          // },
          {
            name: "实收现金",
            mark: "realPaymentMoney"
          },
          {
            name: "缴费时间",
            mark: "userPayingRecordCreateTime", //payTime
            width: "160"
          },
          // {
          //   name: "抄表员",
          //   mark: "readerName"
          // },
          // {
          //   name: "收费员",
          //   mark: "cashier"
          // }
        ],
        tableDataChargeToday: [],
        tableHeaderChargeToday2: [{
            name: "缴费编号",
            mark: "userPayingRecordID",
            fixed: "left"
          },
          {
            name: "用户编号",
            mark: "meterID",
            fixed: "left"
          },
          {
            name: "用户姓名",
            mark: "name",
            fixed: "left"
          },
          {
            name: "小区",
            mark: "villageName",
          },
          {
            name: "用水类型",
            mark: "waterRateName",
          },
          {
            name: "预存水量",
            mark: "depositWaterCount",
          },
          {
            name: "水票费",
            mark: "receiptTotalFee",
          },
          {
            name: "水资源税",
            mark: "tax",
          },
          {
            name: "污水费",
            mark: "effluentFee",
          },
          {
            name: "实收现金",
            mark: "realPaymentMoney",
          },
          {
            name: "缴费时间",
            mark: "userPayingRecordCreateTime", //payTime
            width: "160",
          },
          // {
          //   name: "收费员",
          //   mark: "cashier"
          // }
        ],
        tableDataChargeToday2: [],
        dailyChargeClassify: [],
        dailyChargeData: {
          currWaterCount: "",
          water: "",
          late: "",
          waterAndLate: "",
          effluent: "",
          tax: "",
          realPaymentMoney: ""
        },
        //票据打印按钮禁用
        WreceiptBtn: false,
        SWreceiptBtn: false,
        //票据的数据
        receipt_data: [],
        tableHeaderMeter: [{
            name: "用户编号",
            mark: "meterID",
            minWidth: "90"
          },
          {
            name: "设备类型",
            mark: "meterTypeName",
            minWidth: "90"
          },
          {
            name: "用水类型",
            mark: "waterRateName",
            minWidth: "90"
          },
          {
            name: "当前底数",
            mark: "currReadingValue",
            minWidth: "90"
          },

        ],
        tableOperationMeter: [{
          name: "换表",
          mark: "edit",
          icon: false
        }],
        tablePaginationMeter: {
          show: false,
          current: 1,
          size: 10,
          total: 1
        },
        tableDataMeter: []
      };
    },
    mounted() {
      // this.getData();
    },
    beforeDestroy() {},
    created() {},
    methods: {
      moneyCompute(money) {
        //充值计算
        var self = this;
        var param = {
          userID: self.search.userID,
          depositMoneyAdd: money
        };
        self.$axios
          .post("/service/bsMeterUserDepositWaterAddCompute", param)
          .then(res => {
            if (res.data.status === "success") {
              self.moneyToWater = res.data.res.depositWaterCount;
              self.moneyToCurrSurplus = res.data.res.currSurplus;
            } else {
              self.$message.error(res.data.res);
              self.moneyToWater = 0;
              self.moneyToCurrSurplus = 0;
            }
          });
      },
      moneyAdd(money) {
        //实际充值
        var self = this;
        var param = {
          userID: self.search.userID,
          depositMoneyAdd: money
        };
        self.$axios
          .post("/service/bsMeterUserDepositWaterAdd", param)
          .then(res => {
            if (res.data.status === "success") {
              self.$message.success(res.data.res);
              self.getData();
            } else {
              self.$message.error(res.data.res);
            }
          });
      },

      test5() {
        //修改滞纳时间的接口，临时用的测试 meterReadingRecordID                lateFeeOverTime
        var self = this;
        var param = {
          meterReadingRecordID: self.form.ids.toString(),
          lateFeeOverTime: self.time
        };
        self.$axios.post("/service/bsTmp", param).then(res => {
          if (res.data.status === "success") {
            self.$message.success(res.data.res);
            // 刷新信息
            self.getData();
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      //今日收费（自己）
      getChargeToday() {
        var self = this;
        self.tableDataChargeToday = [];
        self.tableDataChargeToday2 = [];
        self.dailyChargeClassify = [];
        self.dailyChargeData = {
          currWaterCount: "",
          water: "",
          late: "",
          waterAndLate: "",
          effluent: "",
          tax: "",
          realPaymentMoney: ""
        };
        self.showChargeToday = true;
        self.getPayingRecord();
        self.getAddRecord();
        self.$axios.post("/service/bsDailyChargeClassify").then((res) => {
          if (res.data.status === "success") {
            self.dailyChargeClassify = res.data.res;
          } else {
            self.$message.error(res.data.res);
          }
        });
        self.$axios.post("/service/bsDailyCharge").then((res) => {
          if (res.data.status === "success") {
            self.dailyChargeData = res.data.res;
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      //今日收费记录
      getPayingRecord() {
        var self = this;
        var param = {
          pageNum: self.tablePaginationChargeToday.current, //页码
          pageSize: self.tablePaginationChargeToday.size, //条数
        };
        self.$axios.post("/service/bsPayingRecordGetC", param).then((res) => {
          if (res.data.status === "success") {
            self.tableDataChargeToday = res.data.res;
            self.tablePaginationChargeToday.total = res.data.total;
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      //今日充值记录
      getAddRecord() {
        var self = this;
        var param = {
          pageNum: self.tablePaginationChargeToday2.current, //页码
          pageSize: self.tablePaginationChargeToday2.size, //条数
        };
        self.$axios.post("/service/bsPayingRecordGetD", param).then((res) => {
          if (res.data.status === "success") {
            self.tableDataChargeToday2 = res.data.res;
            self.tablePaginationChargeToday2.total = res.data.total;
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      pageSizeChangeChargeToday(data) {
        const self = this;
        self.tablePaginationChargeToday.size = data;
        self.getPayingRecord();
      },
      currentPageChangeChargeToday(data) {
        const self = this;
        self.tablePaginationChargeToday.current = data;
        self.getPayingRecord();
      },
      pageSizeChangeChargeToday2(data) {
        const self = this;
        self.tablePaginationChargeToday2.size = data;
        self.getAddRecord();
      },
      currentPageChangeChargeToday2(data) {
        const self = this;
        self.tablePaginationChargeToday2.current = data;
        self.getAddRecord();
      },
      async getData() {
        //
        var self = this;

        var userID = "";

        userID = self.search.userID;

        if (!userID) {
          self.$message.error("用户编号不能为空！");
          return false;
        }
        await self.getUserByUserID();
        await self.getData1();
        await self.getData2();
        await self.getData3();
        await self.getData4();
        self.clearForm();
        self.activeName="first"
        self.dropdownValue= 0
      },
      getSearch() {
        var self = this;
        self.onReturn();
        if (self.search.type == "userID") {
          self.getData();
          return false;
        }
        self.tablePagination.size = 10;
        self.tablePagination.current = 1;
        //手机号
        if (self.search.type == "phone" && !self.search.phone) {
          self.$message.error("手机号不能为空！");
          return false;
        }
        //姓名
        if (self.search.type == "name" && !self.search.name) {
          self.$message.error("姓名不能为空！");
          return false;
        }
        //住址
        if (self.search.type == "address" && !self.search.address) {
          self.$message.error("地址不能为空！");
          return false;
        }

        //水表编号
        if (self.search.type == "meterID" && !self.search.meterID) {
          self.$message.error("编号不能为空！");
          return false;
        }

        self.getUserList();
      },
      slectUserIDByTable(rows) {
        //选中的用户id改变的时候
        if (rows) {
          this.changeAfterUserID = rows.userID;
        }
      },
      changeUser() {
        //点击确定切换当前用户信息
        const self = this;
        self.showUserList = false;
        if (self.changeAfterUserID) {
          self.search.userID = self.changeAfterUserID;
          self.getData();
        }
      },
      getUserList() {
        //获取用户列表
        const self = this;
        var param = {
          phone: self.search.phone,
          name: self.search.name,
          villageName: self.search.address,
          meterID: self.search.meterID,

          pageNum: self.tablePagination.current, //页码
          pageSize: self.tablePagination.size //条数
        };
        self.$axios.post("/service/bsUserGet", param).then(res => {
          if (res.data.status === "success") {
            var temp = res.data.res;
            self.tableData = temp;
            self.tablePagination.total = res.data.total;
            if (temp.length > 1) {
              //多个用户显示查到的用户列表
              self.changeAfterUserID = "";
              self.showUserList = true;
            } else if (temp.length == 1) {
              self.search.userID = temp[0].userID;
              self.getData();
            } else {
              //清空
              self.tableData1 = [];
              self.tableData2 = [];
              self.tableData3 = [];
              self.tableData4 = [];
              self.$message.error("没有查询到相关用户信息！");
              self.currentObj = {};
              self.tableDataMeter = []
              self.clearForm();
            }
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      pageSizeChange(data) {
        const self = this;
        self.tablePagination.size = data;
        self.getUserList();
      },
      currentPageChange(data) {
        const self = this;
        self.tablePagination.current = data;
        self.getUserList();
      },
      clearForm() {
        var self = this;
        //清空右侧缴费信息
        self.form = {
          ids: [], //账单号
          isPrint: "1", //是否打印发票
          checked: true, //是否找零
          calculateFee: "0.00", //建议实收
          currWaterCount: "0", //用水量
          lateFee: "0.00", //滞纳金
          effluentFee: "0.00", //污水费
          // otherFee: "0.00", //其他费用
          tax: "0.00", //税费
          totalFee: "0.00", //合计
          needPay: "0.00", //应缴
          waterFee: "0.00", //水费
          fromDepositMoney: "0.00", //余额抵扣
          allPrice: "1", //费用/每吨水
          depositMoney: "0" //账户余额
          // fromDepositWater: "0" //水量抵扣
        };
        //清空计算金额的信息
        self.moneyToWater = 0;
        self.moneyToCurrSurplus = 0;
      },
      clearSearch() {
        //清除搜素条件
        var self = this;
        self.search.phone = "";
        self.search.name = "";
        self.search.address = "";
        self.search.meterID = "";
      },
      getData1() {
        //欠费记录
        var self = this;
        if(!self.currentObj.userID){
          return false
        }
        var param = {
          userID: self.search.userID
          // meterReadingRecordStatus: 1
          //   ,
          // pageNum: self.tablePagination1.current, //页码
          // pageSize: self.tablePagination1.size //条数
        };
        self.$axios
          .post("/service/bsMeterReadingNoPayRecordGet", param)
          .then(res => {
            if (res.data.status === "success") {
              var temp = res.data.res;
              self.tableData1 = temp;
              self.tablePagination1.total = res.data.total;
              if (temp.length > 0 && self.currentObj.userMeterTypeID != 4) {
                //欠费记录不为空时默认选中全部记录
                self.$nextTick(() => {
                  self.$refs.multipleTable.$children[2].toggleAllSelection();
                });
              }
            } else {
              self.$message.error(res.data.res);
            }
          });
      },
      pageSizeChange1(data) {
        const self = this;
        self.tablePagination1.size = data;
        self.getData1();
      },
      currentPageChange1(data) {
        const self = this;
        self.tablePagination1.current = data;
        self.getData1();
      },
      getData2() {
        //缴费记录   查询缴费信息
        var self = this;
        if(!self.currentObj.userID){
          return false
        }
        var param = {
          userID: self.search.userID,
          pageNum: self.tablePagination2.current, //页码
          pageSize: self.tablePagination2.size //条数
        };
        self.$axios.post("/service/bsPayingRecordGetAA", param).then(res => { //bsPayingRecordGet（废）
          if (res.data.status === "success") {
            var temp = res.data.res;
            self.tableData2 = temp;
            self.tablePagination2.total = res.data.total;
            self.getSpanArr(self.tableData2);
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      pageSizeChange2(data) {
        const self = this;
        self.tablePagination2.size = data;
        self.getData2();
      },
      currentPageChange2(data) {
        const self = this;
        self.tablePagination2.current = data;
        self.getData2();
      },
      getData3() {
        //全部抄表记录
        var self = this;
        if(!self.currentObj.userID){
          return false
        }
        var param = {
          userID: self.search.userID,
          pageNum: self.tablePagination3.current, //页码
          pageSize: self.tablePagination3.size //条数
        };
        self.$axios
          .post("/service/bsMeterReadingPaydRecordGet", param)
          .then(res => {
            if (res.data.status === "success") {
              var temp = res.data.res;
              self.tableData3 = temp;
              self.tablePagination3.total = res.data.total;
            } else {
              self.$message.error(res.data.res);
            }
          });
      },
      pageSizeChange3(data) {
        const self = this;
        self.tablePagination3.size = data;
        self.getData3();
      },
      currentPageChange3(data) {
        const self = this;
        self.tablePagination3.current = data;
        self.getData3();
      },
      getData4() {
        //充值记录
        var self = this;
        if(!self.currentObj.userID){
          return false
        }
        var param = {
          userID: self.search.userID,
          pageNum: self.tablePagination4.current, //页码
          pageSize: self.tablePagination4.size //条数
        };
        self.$axios
          .post("/service/bsMeterUserDepositWaterAddRecordGet", param)
          .then(res => {
            if (res.data.status === "success") {
              var temp = res.data.res;
              self.tableData4 = temp;
              self.tablePagination4.total = res.data.total;
            } else {
              self.$message.error(res.data.res);
            }
          });
      },
      pageSizeChange4(data) {
        const self = this;
        self.tablePagination4.size = data;
        self.getData4();
      },
      currentPageChange4(data) {
        const self = this;
        self.tablePagination4.current = data;
        self.getData4();
      },
      async getUserByUserID() {
        //根据id查询指定用户的详细信息
        const self = this;

        var param = {
          userID: self.search.userID
        };

        await self.$axios.post("/service/bsMeterUserGet", param).then(res => {
          if (res.data.status === "success") {
            self.currentObj = res.data.res;
            self.tableDataMeter = self.currentObj.meters;
          } else {
            //清空基础数据
            self.currentObj = {};
            self.tableDataMeter = []
          }
          if (!Object.keys(self.currentObj).length > 0) {
            self.$message.error("未查询到相关用户，请确认输入的编号无误！");
            return false;
          }
        });
      },
      handlePageOperation2(row, mark) {
        const self = this;
        if (mark == "close") {
          //取消抄表
          this.$confirm("确定要取消此缴费记录吗?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            })
            .then(() => {
              this.userPayingCancel(row.userPayingRecordID);
            })
            .catch(() => {});
        } else if (mark == "delete") {}
      },
      handlePageOperation3(row, mark) {
        const self = this;
        // if (mark == "refresh-left") {
        //取消抄表
        this.$confirm("确定要取消此抄表记录吗?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
          .then(() => {
            this.meterReadingCancel(row.meterReadingRecordID);
          })
          .catch(() => {});
        // } else if (mark == "close") {
        //   //取消抄表
        //   this.$confirm("确定要取消此缴费记录吗?", "提示", {
        //     confirmButtonText: "确定",
        //     cancelButtonText: "取消",
        //     type: "warning"
        //   })
        //     .then(() => {
        //       this.userPayingCancel(row.userPayingRecordID);
        //     })
        //     .catch(() => {});
        // }
      },
      handlePageOperation4(row, mark) {
        const self = this;
        if (mark == "close") {
          //取消抄表
          this.$confirm("确定要取消此充值吗?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            })
            .then(() => {
              this.meterUserDepositWaterAddCancel(row.userPayingRecordID);
            })
            .catch(() => {});
        }
      },
      userPayingCancel(id) {
        //取消收费
        var self = this;
        var param = {
          userPayingRecordID: id
        };
        self.$axios.post("/service/bsUserPayingCancel", param).then(res => {
          if (res.data.status === "success") {
            self.$message(res.data.res);
            self.getData();
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      meterUserDepositWaterAddCancel(id) {
        //取消充值
        var self = this;
        var param = {
          userPayingRecordID: id
        };
        self.$axios
          .post("/service/bsMeterUserDepositWaterAddCancel", param)
          .then(res => {
            if (res.data.status === "success") {
              self.$message(res.data.res);
              self.getData();
            } else {
              self.$message.error(res.data.res);
            }
          });
      },
      meterReadingCancel(id) {
        //取消抄表
        var self = this;
        var param = {
          meterReadingRecordID: id
        };
        self.$axios.post("/service/bsMeterReadingCancel", param).then(res => {
          if (res.data.status === "success") {
            self.$message(res.data.res);
            self.getData();
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      bsMetersPayingCompute(ids) {
        //计算金额
        var self = this;
        var param = {
          meterReadingRecordIDs: ids.toString(),
          userID: self.search.userID
        };
        self.$axios.post("/service/bsMetersPayingCompute", param).then(res => {
          if (res.data.status === "success") {
            // self.$message("计算水费中");
            //把金额赋值
            self.form.calculateFee = res.data.res.calculateFee;
            self.form.currWaterCount = res.data.res.currWaterCount;
            self.form.lateFee = res.data.res.lateFee;
            // self.form.otherFee = res.data.res.otherFee;
            self.form.tax = res.data.res.tax;
            self.form.totalFee = res.data.res.totalFee;
            self.form.waterFee = res.data.res.waterFee;
            self.form.effluentFee = res.data.res.effluentFee;
            self.form.needPay = res.data.res.needPay;
            self.form.fromDepositMoney = res.data.res.fromDepositMoney;
            self.form.allPrice = res.data.res.allPrice;
            self.form.depositMoney = res.data.res.depositMoney;
            // self.form.fromDepositWater = res.data.res.fromDepositWater;
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      selectionChange(rows) {
        //选中的id改变的时候
        var self = this;

        if (rows && rows.length > 0) {
          self.form.ids = [];
          // self.showPrintBtn = false; //这条语句会在缴一部分费用时，没有打票自动跳转回缴费
          rows.forEach(element => {
            self.form.ids.push(element.meterReadingRecordID);
          });
          self.bsMetersPayingCompute(self.form.ids);
        } else if (rows && rows.length == 0) {
          self.form.ids = [];
          self.clearForm();
        } else {
          //单选行
        }
      },

      onSubmit() {
        //缴费
        var self = this;
        if (!self.search.userID) {
          self.$message.error("用户编号不能为空！");
          return false;
        } else if (!self.form.ids.length > 0) {
          // self.$message.error("请至少选择一条欠费记录！");   
          //没有欠费记录就调充值接口
          if (!self.form.calculateFee > 0) {
            return false
          }
          self.$confirm("确定要给当前用户充值吗?<br>充值金额：" + self.form.calculateFee + "元<br>自动存入水量：" + self.moneyToWater +
              "吨　　余：" + self.formatFixed(self.moneyToCurrSurplus) + "元", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
                dangerouslyUseHTMLString: true
              })
            .then(() => {
              self.moneyAdd(self.form.calculateFee);
            })
            .catch(() => {});

          return false;
        }
        if (self.form.calculateFee < self.form.needPay) {
          self.$message.error("当前输入的金额不足支付本次费用！");
          return false;
        }

        self.receipt_data = [];
        var param = {
          userID: self.search.userID,
          meterReadingRecordIDs: self.form.ids.toString(),
          inputMoney: self.form.calculateFee
        };
        if (!self.form.checked) {
          //不转入零钱，该付多少付多少
          param.inputMoney = self.form.needPay;
        }
        self.$axios.post("/service/bsUserPayingSubmit", param).then(res => {
          if (res.data.status === "success") {
            self.receipt_data = res.data.receiptInfo;
            self.tableDataPrint = res.data.receiptInfo;
            // 刷新信息
            self.getData();
            //如果勾了打印，显示打印按钮
            if (self.form.isPrint == 1) {
              self.showPrintBtn = true;
            }
          } else {
            self.$message.error(res.data.res);
          }
        });
      },
      formatFixed(str) {
        var num = str.toFixed(2);
        return num;
      },
      getSpanArr(data) {
        this.spanArr = [];
        for (var i = 0; i < data.length; i++) {
          if (i === 0) {
            this.spanArr.push(1);
            this.pos = 0;
          } else {
            // 判断当前元素与上一个元素是否相同,因合并第一个所以[0]
            if (data[i].userPayingRecordID === data[i - 1].userPayingRecordID) {
              this.spanArr[this.pos] += 1;
              this.spanArr.push(0);
            } else {
              this.spanArr.push(1);
              this.pos = i;
            }
          }
        }
      },
      objectSpanMethod({
        row,
        column,
        rowIndex,
        columnIndex
      }) {
        var colsIndex = [0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
        if (colsIndex.includes(columnIndex)) {
          const _row = this.spanArr[rowIndex];
          const _col = _row > 0 ? 1 : 0;
          return {
            rowspan: _row,
            colspan: _col
          };
        }
      },
      //返回缴费
      onReturn() {
        const self = this;
        self.showPrintBtn = false;
        self.WreceiptBtn = false;
        self.SWreceiptBtn = false;
      },
      //打印方法
      // 水费票据打印
      WPrintWaitLoop() {
        const self = this;
        self.WreceiptBtn = true;
        LODOP = getLodop();
        for (let i in self.receipt_data) {
          LODOP.PRINT_INITA("-5mm", "-10mm", "190mm", "102mm", "水费");
          LODOP.SET_PRINT_PAGESIZE(1, "190mm", "102mm", "");
          self.AddWPrintContent(self.receipt_data[i]);
          LODOP.PRINT();
          // if (i == self.receipt_data.length - 1) {
          //   self.$message.success("水费票打印结束！");
          // }
        }
      },
      // 污水费票据打印
      SWPrintWaitLoop() {
        const self = this;
        self.SWreceiptBtn = true;
        LODOP = getLodop();
        for (let i in self.receipt_data) {
          if (self.receipt_data[i].effluentFee != 0) {
            LODOP.PRINT_INITA("-5mm", "-10mm", "240mm", "76mm", "污水费");
            LODOP.SET_PRINT_PAGESIZE(1, 0, "76mm", "A3");
            self.AddSWPrintContent(self.receipt_data[i]);
            LODOP.PRINT();
          }
          // if (i == self.receipt_data.length - 1) {
          //   self.$message.success("污水票打印结束！");
          // }
        }
      },
      // 水费票据内容
      AddWPrintContent(WreceiptData) {
        const self = this;
        LODOP.SET_PRINT_STYLE("FontName", "微软雅黑");
        LODOP.SET_PRINT_STYLE("FontSize", 11);
        LODOP.ADD_PRINT_TEXT("20mm", "40mm", "30mm", "6mm", WreceiptData.payTime.split(" ")[0]);
        LODOP.ADD_PRINT_TEXT("30mm", "20mm", "20mm", "8mm", "用户编号");
        LODOP.ADD_PRINT_TEXT(
          "30mm",
          "37mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.meterID
        );
        LODOP.ADD_PRINT_TEXT("30mm", "70mm", "20mm", "8mm", "用户姓名");
        LODOP.ADD_PRINT_TEXT(
          "30mm",
          "87mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.meterUserName
        );
        LODOP.ADD_PRINT_TEXT("30mm", "120mm", "23mm", "8mm", "抄表员");
        LODOP.ADD_PRINT_TEXT(
          "30mm",
          "140mm",
          "30mm",
          "8mm",
          "：" + WreceiptData.readerName
        );
        LODOP.ADD_PRINT_TEXT("38mm", "20mm", "20mm", "8mm", "用户地址");
        LODOP.ADD_PRINT_TEXT(
          "38mm",
          "37mm",
          "83mm",
          "8mm",
          "：" + WreceiptData.villageName + WreceiptData.villageDetail
        );
        LODOP.ADD_PRINT_TEXT("38mm", "120mm", "23mm", "8mm", "用水月份");
        LODOP.ADD_PRINT_TEXT(
          "38mm",
          "140mm",
          "30mm",
          "8mm",
          "：" + WreceiptData.period
        );
        LODOP.ADD_PRINT_TEXT("46mm", "20mm", "20mm", "8mm", "上期指数");
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "37mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.lastReadingValue
        );
        LODOP.ADD_PRINT_TEXT("46mm", "70mm", "20mm", "8mm", "本期指数");
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "87mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.currReadingValue
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "120mm",
          "23mm",
          "8mm",
          WreceiptData.waterRateName
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "140mm",
          "30mm",
          "8mm",
          "：" + WreceiptData.currWaterFee
        );
        LODOP.ADD_PRINT_TEXT("54mm", "20mm", "20mm", "8mm", "抵扣水量");
        LODOP.ADD_PRINT_TEXT(
          "54mm",
          "37mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.readingFromDepositWater
        );
        LODOP.ADD_PRINT_TEXT("54mm", "70mm", "20mm", "8mm", "用水量");
        LODOP.ADD_PRINT_TEXT(
          "54mm",
          "87mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.currWaterCount
        );
        LODOP.ADD_PRINT_TEXT("54mm", "120mm", "23mm", "8mm", "滞纳天数");
        LODOP.ADD_PRINT_TEXT(
          "54mm",
          "140mm",
          "30mm",
          "8mm",
          "：" + WreceiptData.lateDays
        );
        LODOP.ADD_PRINT_TEXT("62mm", "20mm", "20mm", "8mm", "预存水费");
        LODOP.ADD_PRINT_TEXT(
          "62mm",
          "37mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.currDepositWaterMoney
        );
        LODOP.ADD_PRINT_TEXT("62mm", "70mm", "20mm", "8mm", "水费");
        LODOP.ADD_PRINT_TEXT(
          "62mm",
          "87mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.realWaterFee
        );
        LODOP.ADD_PRINT_TEXT("62mm", "120mm", "23mm", "8mm", "滞纳金");
        LODOP.ADD_PRINT_TEXT(
          "62mm",
          "140mm",
          "30mm",
          "8mm",
          "：" + WreceiptData.realLateFee
        );
        LODOP.ADD_PRINT_TEXT("70mm", "20mm", "20mm", "8mm", "上期余额");
        LODOP.ADD_PRINT_TEXT(
          "70mm",
          "37mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.lastSurplus
        );
        LODOP.ADD_PRINT_TEXT("70mm", "70mm", "20mm", "8mm", "本期余额");
        LODOP.ADD_PRINT_TEXT(
          "70mm",
          "87mm",
          "33mm",
          "8mm",
          "：" + WreceiptData.currSurplus
        );
        LODOP.ADD_PRINT_TEXT("70mm", "120mm", "23mm", "8mm", "总计金额");
        LODOP.ADD_PRINT_TEXT(
          "70mm",
          "140mm",
          "30mm",
          "8mm",
          "：" + WreceiptData.receiptTotalFee
        );
        LODOP.ADD_PRINT_TEXT("78mm", "20mm", "33mm", "8mm", "总计金额大写：");
        LODOP.ADD_PRINT_TEXT(
          "78mm",
          "50mm",
          "117mm",
          "8mm",
          self.convertCurrency(WreceiptData.receiptTotalFee)
        );
        LODOP.ADD_PRINT_TEXT(
          "94mm",
          "149mm",
          "20mm",
          "6mm",
          WreceiptData.cashier
        );
      },
      // 污水费票据内容
      AddSWPrintContent(SWreceiptData) {
        const self = this;
        LODOP.SET_PRINT_STYLE("FontName", "微软雅黑");
        LODOP.SET_PRINT_STYLE("FontSize", 11);
        //污水票上面的时间
        var payingTime = SWreceiptData.payTime.split(" ");
        var top_data_str = payingTime[0].split("-");
        var top_data_year = top_data_str[0];
        var top_data_month = top_data_str[1];
        var top_data_day = top_data_str[2];
        LODOP.ADD_PRINT_TEXT("21mm", "83mm", "13mm", "6mm", top_data_year);
        LODOP.ADD_PRINT_TEXT("21mm", "100mm", "8mm", "6mm", top_data_month);
        LODOP.ADD_PRINT_TEXT("21mm", "109mm", "8mm", "6mm", top_data_day);
        LODOP.ADD_PRINT_TEXT(
          "29mm",
          "22mm",
          "44mm",
          "8mm",
          SWreceiptData.meterUserName
        );
        LODOP.ADD_PRINT_TEXT(
          "29mm",
          "76mm",
          "40mm",
          "8mm",
          SWreceiptData.villageName + SWreceiptData.villageDetail
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "22mm",
          "15mm",
          "10mm",
          SWreceiptData.currReadingValue
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "40mm",
          "20mm",
          "10mm",
          SWreceiptData.waterRateName
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "60mm",
          "13mm",
          "10mm",
          SWreceiptData.currEffluentFee
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "78mm",
          "15mm",
          "10mm",
          SWreceiptData.otherCurrWaterCount
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "100mm",
          "15mm",
          "10mm",
          SWreceiptData.effluentFee
        );
        LODOP.ADD_PRINT_TEXT(
          "58mm",
          "25mm",
          "90mm",
          "8mm",
          self.convertCurrency(SWreceiptData.effluentFee)
        );
        LODOP.ADD_PRINT_TEXT(
          "66mm",
          "35mm",
          "20mm",
          "6mm",
          SWreceiptData.cashier
        );
        LODOP.ADD_PRINT_TEXT("66mm", "93mm", "25mm", "6mm", payingTime[0]);

        LODOP.ADD_PRINT_TEXT("21mm", "193mm", "13mm", "6mm", top_data_year);
        LODOP.ADD_PRINT_TEXT("21mm", "210mm", "8mm", "6mm", top_data_month);
        LODOP.ADD_PRINT_TEXT("21mm", "219mm", "8mm", "6mm", top_data_day);
        LODOP.ADD_PRINT_TEXT(
          "29mm",
          "132mm",
          "44mm",
          "8mm",
          SWreceiptData.meterUserName
        );
        LODOP.ADD_PRINT_TEXT(
          "29mm",
          "186mm",
          "40mm",
          "8mm",
          SWreceiptData.villageName + SWreceiptData.villageDetail
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "132mm",
          "15mm",
          "10mm",
          SWreceiptData.currReadingValue
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "150mm",
          "20mm",
          "10mm",
          SWreceiptData.waterRateName
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "170mm",
          "13mm",
          "10mm",
          SWreceiptData.currEffluentFee
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "188mm",
          "15mm",
          "10mm",
          SWreceiptData.otherCurrWaterCount
        );
        LODOP.ADD_PRINT_TEXT(
          "46mm",
          "210mm",
          "15mm",
          "10mm",
          SWreceiptData.effluentFee
        );
        LODOP.ADD_PRINT_TEXT(
          "58mm",
          "135mm",
          "90mm",
          "8mm",
          self.convertCurrency(SWreceiptData.effluentFee)
        );
        LODOP.ADD_PRINT_TEXT(
          "66mm",
          "145mm",
          "20mm",
          "6mm",
          SWreceiptData.cashier
        );
        LODOP.ADD_PRINT_TEXT("66mm", "203mm", "25mm", "6mm", payingTime[0]);
      },
      // 兑换货币，小写转大写
      convertCurrency(money) {
        //汉字的数字
        var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
        //基本单位
        var cnIntRadice = new Array('', '拾', '佰', '仟');
        //对应整数部分扩展单位
        var cnIntUnits = new Array('', '万', '亿', '兆');
        //对应小数部分单位
        var cnDecUnits = new Array('角', '分', '毫', '厘');
        //整数金额时后面跟的字符
        var cnInteger = '整';
        //整型完以后的单位
        var cnIntLast = '元';
        //最大处理的数字
        var maxNum = 999999999999999.9999;
        //金额整数部分
        var integerNum;
        //金额小数部分
        var decimalNum;
        //输出的中文金额字符串
        var chineseStr = '';
        //分离金额后用的数组，预定义
        var parts;
        if (money == '') {
          return '';
        }
        money = parseFloat(money);
        if (money >= maxNum) {
          //超出最大处理数字
          return '';
        }
        if (money == 0) {
          chineseStr = cnNums[0] + cnIntLast + cnInteger;
          return chineseStr;
        }
        //转换为字符串
        money = money.toString();
        if (money.indexOf('-') == 0) {
          chineseStr = '（负数）'
          money = money.substr(1)
        }
        if (money.indexOf('.') == -1) {
          integerNum = money;
          decimalNum = '';
        } else {
          parts = money.split('.');
          integerNum = parts[0];
          decimalNum = parts[1].substr(0, 4);
        }
        //获取整型部分转换
        if (parseInt(integerNum, 10) > 0) {
          var zeroCount = 0;
          var IntLen = integerNum.length;
          for (var i = 0; i < IntLen; i++) {
            var n = integerNum.substr(i, 1);
            var p = IntLen - i - 1;
            var q = p / 4;
            var m = p % 4;
            if (n == '0') {
              zeroCount++;
            } else {
              if (zeroCount > 0) {
                chineseStr += cnNums[0];
              }
              //归零
              zeroCount = 0;
              chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
            }
            if (m == 0 && zeroCount < 4) {
              chineseStr += cnIntUnits[q];
            }
          }
          chineseStr += cnIntLast;
        }
        //小数部分
        if (decimalNum != '') {
          var decLen = decimalNum.length;
          for (var i = 0; i < decLen; i++) {
            var n = decimalNum.substr(i, 1);
            if (n != '0') {
              chineseStr += cnNums[Number(n)] + cnDecUnits[i];
            }
          }
        }
        if (chineseStr == '') {
          chineseStr += cnNums[0] + cnIntLast + cnInteger;
        } else if (decimalNum == '') {
          chineseStr += cnInteger;
        }
        return chineseStr;
      },
      focusCalculateFee(e) { //获取焦点时选中文字
        this.$refs.inputCalculateFee.select()
      },
      changeCalculateFee(e) { //改变金额的时候，重新计算结余
        //
        this.moneyToWater = 0;
        this.moneyToCurrSurplus = 0;
        if (!this.search.userID) {
          this.$message.error("用户编号不能为空！");
          return false;
        }

        var reg = /^([1-9][0-9]*)+(.[0-9]{1,2})?$/;
        if (!reg.test(e)) {
          this.$message.error("请输入有效的金额！");
          this.$refs.inputCalculateFee.focus();
          this.form.calculateFee = "";
          return false;
        }

        //如果是未欠费用户/未勾选欠费信息
        if (!this.form.ids.length > 0) {
          this.moneyCompute(e);
        }
        //如果勾选了欠费信息，走缴费后的计算



      },
      handleCommand(index) { //切换显示用户信息和水表信息
        this.dropdownValue = index
      },
      bottomTabClick(e){//切换选项卡选中时刷新当前数据
        var self=this;
        switch (e.name) {
          case "first":
            self.getData1();
            break;
          case "second":
            self.getData2();
            break;
          case "third":
            self.getData3();
            break;
          case "fourth":
            self.getData4();
            break;
        
          default:
            break;
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .tableDetail {
    th {
      width: 90px;
    }
  }

  .sanfan-fieldset {
    min-height: 372px;
    width: 100%;
    min-width: 100px;
  }

  .print_form_item {
    margin-bottom: 0;
  }

  // .yysfBox .el-form-item{
  //   float: none;
  // }
  // .fr{float: right!important;}
</style>